package cn.com.wdjedu.androidapp.wjeduandroid.ui.videoshow.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.com.wdjedu.androidapp.wjeduandroid.R;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.MvpFragment;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.video.videoBean;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.video.videoPresenter;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.video.videoview;
import cn.com.wdjedu.androidapp.wjeduandroid.support.lib.Constanct;
import cn.com.wdjedu.androidapp.wjeduandroid.ui.videoshow.VideoShowActivity;

/**
 * 視頻詳情页面
 */
public class VideoShowDeatilsFragment extends MvpFragment<videoPresenter> implements videoview {
    @BindView(R.id.teacherPicture)
    ImageView teacherPicture;
    @BindView(R.id.teacherDetails)
    TextView teacherDetails;
    @BindView(R.id.teacher_name)
    TextView teacherName;

    //private DetailsFragmentAdapter dfa;
    //List<videoBean> lists = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.item_viewshow_details, null);
        ButterKnife.bind(this, view);
        mvpPresenter.attach(this);
        initData();
        return view;
    }

    private void initData() {
        VideoShowActivity ac = (VideoShowActivity) getActivity();
        mvpPresenter.queryVideoData(ac.getPlayId());
        //dfa = new DetailsFragmentAdapter(mContext, R.layout.item_viewshow_details, lists);
        //itemMylistview.setAdapter(ChapterAdapter);

    }

    @Override
    protected videoPresenter createPresenter() {
        return new videoPresenter(this);
    }

    @Override
    protected void lazyLoad() {

    }

    @Override
    public void queryNewVideoData(videoBean VideoBean) {
        //lists.clear();
        //lists.add(VideoBean);
        //dfa.notifyDataSetChanged();
        teacherName.setText("讲师详情："+VideoBean.getTeacher().getName());
        teacherDetails.setText(VideoBean.getTeacher().getDescript());
        ImageLoader.getInstance().displayImage(Constanct.IMAGE_URL2 +VideoBean.getTeacher().getImage(), teacherPicture);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showError(String error) {

    }
}
